package org.yihang.common.spring;

import org.springframework.core.MethodParameter;
import org.springframework.web.bind.support.WebArgumentResolver;
import org.springframework.web.context.request.NativeWebRequest;

public class JsonModelArgumentResolver implements WebArgumentResolver {

	@Override
	public Object resolveArgument(MethodParameter methodParameter, NativeWebRequest webRequest) throws Exception {
		Class<?> type = methodParameter.getParameterType();
		if(type.equals(JsonModel.class)) {
			return new JsonModel();
		}
		return WebArgumentResolver.UNRESOLVED;
	}

}
